/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb;

import java.sql.*;
import java.util.logging.Logger;

/**
 *
 * @author cloud
 */
public class DBManager {

    
    Connection conn;
    Statement st;
    ResultSet rs;
    
    public String letsaGo() {
        String dburl = "jdbc:derby://localhost:1527/sample";
        String dbuser = "app";
        String dbpwd = "app";
        String z = "";
        
        
        try {

            DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
            conn = DriverManager.getConnection(dburl, dbuser, dbpwd);

            st = conn.createStatement();
            
            rs = st.executeQuery("select * from CUSTOMER");
            
            while(rs.next()){
                z += ("Name: "+rs.getString("NAME")+" City: "+rs.getString("CITY") + "\n");
            }
            return z;
            
        } catch (SQLException ex) {
            ex.printStackTrace();
        }finally{
            try {
                rs.close();
                st.close();
                conn.close();
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
        }
        return null;
    }
}